﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace AISservice.Common
{
    public class Log4Net
    {
        private static bool _Log4NetConfigured = false;
        private static void ConfigureLog4Net()
        {
            log4net.Appender.RollingFileAppender fileAppender = new log4net.Appender.RollingFileAppender();
            fileAppender.File = System.AppDomain.CurrentDomain.BaseDirectory + "\\log\\";
            fileAppender.StaticLogFileName = false;
            fileAppender.DatePattern = "yyyy-MM-dd\".log\"";
            fileAppender.RollingStyle = log4net.Appender.RollingFileAppender.RollingMode.Date;
            fileAppender.Layout = new log4net.Layout.PatternLayout("%d [%t]%-5p %c [%x] - %m%n");
            fileAppender.ActivateOptions();
            log4net.Config.BasicConfigurator.Configure(fileAppender);
            _Log4NetConfigured = true;
        }
        private static log4net.ILog GetLog4NetLoger()
        {
            if (!_Log4NetConfigured)
                ConfigureLog4Net();
            return log4net.LogManager.GetLogger("AIS");
        }
        public static void Debug(object message)
        {
            GetLog4NetLoger().Debug(message);
        }
        public static void Debug(object message, Exception exception)
        {
            GetLog4NetLoger().Debug(message, exception);
        }
        public static void DebugFormat(string format, object arg0)
        {
            GetLog4NetLoger().DebugFormat(format, arg0);
        }
        public static void DebugFormat(string format, params object[] args)
        {
            GetLog4NetLoger().DebugFormat(format, args);
        }
        public static void DebugFormat(IFormatProvider provider, string format, params object[] args)
        {
            GetLog4NetLoger().DebugFormat(provider, format, args);
        }
        public static void DebugFormat(string format, object arg0, object arg1)
        {
            GetLog4NetLoger().DebugFormat(format, arg0, arg1);
        }
        public static void DebugFormat(string format, object arg0, object arg1, object arg2)
        {
            GetLog4NetLoger().DebugFormat(format, arg0, arg1, arg2);
        }

        public static void Error(object message)
        {
            GetLog4NetLoger().Error(message);
        }
        public static void Error(object message, Exception exception)
        {
            GetLog4NetLoger().Error(message, exception);
        }
        public static void ErrorFormat(string format, object arg0)
        {
            GetLog4NetLoger().ErrorFormat(format, arg0);
        }
        public static void ErrorFormat(string format, params object[] args)
        {
            GetLog4NetLoger().ErrorFormat(format, args);
        }
        public static void ErrorFormat(IFormatProvider provider, string format, params object[] args)
        {
            GetLog4NetLoger().ErrorFormat(provider, format, args);
        }
        public static void ErrorFormat(string format, object arg0, object arg1)
        {
            GetLog4NetLoger().ErrorFormat(format, arg0, arg1);
        }
        public static void ErrorFormat(string format, object arg0, object arg1, object arg2)
        {
            GetLog4NetLoger().ErrorFormat(format, arg0, arg1, arg2);
        }

        public static void Fatal(object message)
        {
            GetLog4NetLoger().Fatal(message);
        }
        public static void Fatal(object message, Exception exception)
        {
            GetLog4NetLoger().Fatal(message, exception);
        }
        public static void FatalFormat(string format, object arg0)
        {
            GetLog4NetLoger().FatalFormat(format, arg0);
        }
        public static void FatalFormat(string format, params object[] args)
        {
            GetLog4NetLoger().FatalFormat(format, args);
        }
        public static void FatalFormat(IFormatProvider provider, string format, params object[] args)
        {
            GetLog4NetLoger().FatalFormat(provider, format, args);
        }
        public static void FatalFormat(string format, object arg0, object arg1)
        {
            GetLog4NetLoger().FatalFormat(format, arg0, arg1);
        }
        public static void FatalFormat(string format, object arg0, object arg1, object arg2)
        {
            GetLog4NetLoger().FatalFormat(format, arg0, arg1, arg2);
        }

        public static void Info(object message)
        {
            GetLog4NetLoger().Info(message);
        }
        public static void Info(object message, Exception exception)
        {
            GetLog4NetLoger().Info(message, exception);
        }
        public static void InfoFormat(string format, object arg0)
        {
            GetLog4NetLoger().InfoFormat(format, arg0);
        }
        public static void InfoFormat(string format, params object[] args)
        {
            GetLog4NetLoger().InfoFormat(format, args);
        }
        public static void InfoFormat(IFormatProvider provider, string format, params object[] args)
        {
            GetLog4NetLoger().InfoFormat(provider, format, args);
        }
        public static void InfoFormat(string format, object arg0, object arg1)
        {
            GetLog4NetLoger().InfoFormat(format, arg0, arg1);
        }
        public static void InfoFormat(string format, object arg0, object arg1, object arg2)
        {
            GetLog4NetLoger().InfoFormat(format, arg0, arg1, arg2);
        }

        public static void Warn(object message)
        {
            GetLog4NetLoger().Warn(message);
        }
        public static void Warn(object message, Exception exception)
        {
            GetLog4NetLoger().Warn(message, exception);
        }
        public static void WarnFormat(string format, object arg0)
        {
            GetLog4NetLoger().WarnFormat(format, arg0);
        }
        public static void WarnFormat(string format, params object[] args)
        {
            GetLog4NetLoger().WarnFormat(format, args);
        }
        public static void WarnFormat(IFormatProvider provider, string format, params object[] args)
        {
            GetLog4NetLoger().WarnFormat(provider, format, args);
        }
        public static void WarnFormat(string format, object arg0, object arg1)
        {
            GetLog4NetLoger().WarnFormat(format, arg0, arg1);
        }
        public static void WarnFormat(string format, object arg0, object arg1, object arg2)
        {
            GetLog4NetLoger().WarnFormat(format, arg0, arg1, arg2);
        }
    }
}
